API Documentation
Vector.h
1 // Vector.h
3 //
5 
6 namespace nkMaths
7 {
11  class Vector : public ByteAlignedClass<16>
12  {
13  public :
14 
15  float _x ;
16  float _y ;
17  float _z ;
18  float _w ;
19 
20  public :
21 
26  Vector () ;
35  Vector (float x, float y) ;
45  Vector (float x, float y, float z) ;
54  Vector (float x, float y, float z, float w) ;
60  Vector (const Vector& other) ;
66  Vector (const IntVector& other) ;
70  ~Vector () ;
71 
75  float getX () const ;
79  float getY () const ;
83  float getZ () const ;
87  float getW () const ;
88 
89  // Setters
95  void setX (float value) ;
101  void setY (float value) ;
107  void setZ (float value) ;
113  void setW (float value) ;
114 
115  // Add
121  void addX (float value) ;
127  void addY (float value) ;
133  void addZ (float value) ;
139  void addW (float value) ;
145  void multX (float value) ;
151  void multY (float value) ;
157  void multZ (float value) ;
163  void multW (float value) ;
164 
165  // Length
169  float getLengthVec2 () const ;
173  float getLengthVec3 () const ;
177  float getLengthVec4 () const ;
183  float getLengthSquaredVec2 () const ;
189  float getLengthSquaredVec3 () const ;
195  float getLengthSquaredVec4 () const ;
196  // Distance
201  float getDistanceVec2 (const Vector& other) const ;
206  float getDistanceVec3 (const Vector& other) const ;
211  float getDistanceVec4 (const Vector& other) const ;
218  float getDistanceSquaredVec2 (const Vector& other) const ;
225  float getDistanceSquaredVec3 (const Vector& other) const ;
232  float getDistanceSquaredVec4 (const Vector& other) const ;
233 
239  void normalizeVec2 () ;
245  void normalizeVec3 () ;
249  void normalizeVec4 () ;
262  // Dot product
269  float dotProductVec2 (const Vector& other) const ;
276  float dotProductVec3 (const Vector& other) const ;
283  float dotProductVec4 (const Vector& other) const ;
284  // Cross product
290  void setAsCrossVec3 (const Vector& other) ;
297  Vector getCrossVec3 (const Vector& other) const ;
298 
299  // Practical
306  void fromString (const std::string_view& str) ;
307 
308  // Operators
315  Vector& operator= (const Vector& other) ;
322  Vector& operator= (const IntVector& other) ;
329  Vector operator+ (const Vector& other) const ;
335  void operator+= (const Vector& other) ;
342  Vector operator- (const Vector& other) const ;
348  void operator-= (const Vector& other) ;
355  Vector operator* (const Vector& other) const ;
361  void operator*= (const Vector& other) ;
368  Vector operator* (const Quaternion& other) const ;
374  void operator*= (const Quaternion& other) ;
381  Vector operator* (const Matrix& mat) const ;
387  void operator*= (const Matrix& other) ;
394  Vector operator* (float coeff) const ;
400  void operator*= (float coeff) ;
407  Vector operator/ (const Vector& other) const ;
413  void operator/= (const Vector& other) ;
420  Vector operator/ (float coeff) const ;
426  void operator/= (float coeff) ;
433  bool operator== (const Vector& other) const ;
440  bool operator!= (const Vector& other) const ;
447  bool operator< (const Vector& other) const ;
454  bool operator<= (const Vector& other) const ;
461  bool operator> (const Vector& other) const ;
468  bool operator>= (const Vector& other) const ;
469 
470  // Statics
471  // Distance
479  static float distanceVec2 (const Vector& a, const Vector& b) ;
487  static float distanceVec3 (const Vector& a, const Vector& b) ;
495  static float distanceVec4 (const Vector& a, const Vector& b) ;
503  static float distanceSquaredVec2 (const Vector& a, const Vector& b) ;
511  static float distanceSquaredVec3 (const Vector& a, const Vector& b) ;
519  static float distanceSquaredVec4 (const Vector& a, const Vector& b) ;
520  // Dot product
528  static float dotVec2 (const Vector& a, const Vector& b) ;
536  static float dotVec3 (const Vector& a, const Vector& b) ;
544  static float dotVec4 (const Vector& a, const Vector& b) ;
545  // Cross product
553  static Vector crossVec3 (const Vector& a, const Vector& b) ;
554  } ;
555 
556  using FloatVector = Vector ;
557 }
nkMaths::Vector::distanceVec3
static float distanceVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthVec4
float getLengthVec4() const
nkMaths::Vector::getZ
float getZ() const
nkMaths::Vector::getDistanceSquaredVec2
float getDistanceSquaredVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector(float x, float y, float z, float w)
nkMaths::Vector::distanceSquaredVec2
static float distanceSquaredVec2(const Vector &a, const Vector &b)
nkMaths::Vector::getY
float getY() const
nkMaths::IntVector
A 4-component vector class, with integers.
Definition: IntVector.h:12
nkMaths::Vector::distanceVec2
static float distanceVec2(const Vector &a, const Vector &b)
nkMaths::Vector::operator>
bool operator>(const Vector &other) const
nkMaths::Vector::setAsCrossVec3
void setAsCrossVec3(const Vector &other)
nkMaths::Vector::getCrossVec3
Vector getCrossVec3(const Vector &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Vector::operator==
bool operator==(const Vector &other) const
nkMaths::Vector::operator<
bool operator<(const Vector &other) const
nkMaths::Vector::operator+=
void operator+=(const Vector &other)
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Vector::operator+
Vector operator+(const Vector &other) const
nkMaths::Vector::getW
float getW() const
nkMaths::Vector::getLengthVec3
float getLengthVec3() const
nkMaths::Vector::multY
void multY(float value)
nkMaths::Vector::distanceSquaredVec4
static float distanceSquaredVec4(const Vector &a, const Vector &b)
nkMaths::Vector::getDistanceVec4
float getDistanceVec4(const Vector &other) const
nkMaths::Vector::dotVec3
static float dotVec3(const Vector &a, const Vector &b)
nkMaths::Vector::setZ
void setZ(float value)
nkMaths::Vector::getLengthSquaredVec2
float getLengthSquaredVec2() const
nkMaths::Vector::dotVec4
static float dotVec4(const Vector &a, const Vector &b)
nkMaths::Vector::_x
float _x
X component of the vector.
Definition: Vector.h:15
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Vector::getDistanceVec2
float getDistanceVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector()
nkMaths::Vector::normalizeVec2
void normalizeVec2()
nkMaths::Vector::setY
void setY(float value)
nkMaths::Vector::addZ
void addZ(float value)
nkMaths::Vector::normalizeVec3
void normalizeVec3()
nkMaths::Vector::multW
void multW(float value)
nkMaths::Vector::getDistanceSquaredVec4
float getDistanceSquaredVec4(const Vector &other) const
nkMaths::Vector::operator*
Vector operator*(const Vector &other) const
nkMaths::Vector::distanceSquaredVec3
static float distanceSquaredVec3(const Vector &a, const Vector &b)
nkMaths::Vector::operator-=
void operator-=(const Vector &other)
nkMaths::Vector::setW
void setW(float value)
nkMaths::Vector::operator<=
bool operator<=(const Vector &other) const
nkMaths::Vector::Vector
Vector(const Vector &other)
nkMaths::Vector::multX
void multX(float value)
nkMaths::Vector::~Vector
~Vector()
nkMaths::Vector::setX
void setX(float value)
nkMaths::Vector::addX
void addX(float value)
nkMaths::Vector::addY
void addY(float value)
nkMaths::Vector::operator/=
void operator/=(const Vector &other)
nkMaths::Vector::Vector
Vector(const IntVector &other)
nkMaths::Vector::crossVec3
static Vector crossVec3(const Vector &a, const Vector &b)
nkMaths::Vector::dotProductVec3
float dotProductVec3(const Vector &other) const
nkMaths::Vector::operator>=
bool operator>=(const Vector &other) const
nkMaths::Vector::_z
float _z
Z component of the vector.
Definition: Vector.h:17
nkMaths::Vector::_w
float _w
W component of the vector.
Definition: Vector.h:18
nkMaths::Vector::getLengthSquaredVec3
float getLengthSquaredVec3() const
nkMaths::Vector::dotProductVec4
float dotProductVec4(const Vector &other) const
nkMaths::Vector::getDistanceVec3
float getDistanceVec3(const Vector &other) const
nkMaths::Vector::getNormalizedVec2
Vector getNormalizedVec2() const
nkMaths::Vector::getNormalizedVec3
Vector getNormalizedVec3() const
nkMaths::Vector::Vector
Vector(float x, float y)
nkMaths::Vector::fromString
void fromString(const std::string_view &str)
nkMaths::Vector::_y
float _y
Y component of the vector.
Definition: Vector.h:16
nkMaths::Vector::getNormalizedVec4
Vector getNormalizedVec4() const
nkMaths::Vector::getLengthVec2
float getLengthVec2() const
nkMaths::Vector::dotProductVec2
float dotProductVec2(const Vector &other) const
nkMaths::Vector::operator-
Vector operator-(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec4
float getLengthSquaredVec4() const
nkMaths::Vector::multZ
void multZ(float value)
nkMaths::Vector::addW
void addW(float value)
nkMaths::Vector::operator!=
bool operator!=(const Vector &other) const
nkMaths::Vector::operator*=
void operator*=(const Vector &other)
nkMaths::Vector::operator/
Vector operator/(const Vector &other) const
nkMaths::Vector::getX
float getX() const
nkMaths::Vector::getDistanceSquaredVec3
float getDistanceSquaredVec3(const Vector &other) const
nkMaths::Vector::operator=
Vector & operator=(const Vector &other)
nkMaths::Vector::Vector
Vector(float x, float y, float z)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Vector::distanceVec4
static float distanceVec4(const Vector &a, const Vector &b)
nkMaths::Vector::normalizeVec4
void normalizeVec4()
nkMaths::Vector::dotVec2
static float dotVec2(const Vector &a, const Vector &b)